﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Demo.Services.Contracts.DTO.Infos;
using Demo.Services.Integration.DAO.Impl;
using Demo.CommonBase.Logging;
using Demo.CommonBase.Exceptions;
using System.Reflection;
using Demo.CommonBase.DTO.Infos;
using Demo.Services.Contracts.DTO.Filters;

namespace Demo.Services.Services.Impl.DomainObjects
{
    public class TecnologyDomainObject
    {
        public TecnologyResultInfo GetTecnologies(PaginationInfo pagin, TecnologyFilter filters)
        {
            TecnologyResultInfo result  = null;
            TecnologyDAO tecnologyDao;
            try
            {
                //Logger.Info();
                tecnologyDao = new TecnologyDAO();
                result = tecnologyDao.GetTecnologies(pagin,filters);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return result;
        }
        public TecnologyInfo GetTecnologyById(int id)
        {
            TecnologyInfo result = null;
            TecnologyDAO tecnologyDao;
            try
            {
                //Logger.Info();
                tecnologyDao = new TecnologyDAO();
                result = tecnologyDao.GetTecnologyById(id);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return result;
        }
        public void DeleteTecnology(int id)
        {
            TecnologyDAO tecnologyDao;
            try
            {
                //Logger.Info();
                tecnologyDao = new TecnologyDAO();
                tecnologyDao.DeleteTecnology(id);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
        }
        public void UpdateTecnology(TecnologyInfo tecnology)
        {
            TecnologyDAO tecnologyDao;
            try
            {
                //Logger.Info();
                tecnologyDao = new TecnologyDAO();
                tecnologyDao.UpdateTecnology(tecnology);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
        }
        public void SaveTecnology(TecnologyInfo tecnology)
        {
            TecnologyDAO tecnologyDao;
            try
            {
                //Logger.Info();
                tecnologyDao = new TecnologyDAO();
                tecnologyDao.SaveTecnology(tecnology);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
        }
       
        public List<TecnologyInfo> GetTecnologysByProyect(int proyectId)
        {
            List<TecnologyInfo> result = null;
            TecnologyDAO tecnologyDao;
            try
            {
                Logger.Info();
                tecnologyDao = new TecnologyDAO();
                result = tecnologyDao.GetTecnologysByProyect(proyectId);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return result;
        }

        public List<TecnologyInfo> GetTecnologysByResource(int resourceId)
        {
            List<TecnologyInfo> result = null;
            TecnologyDAO tecnologyDao;
            try
            {
                Logger.Info();
                tecnologyDao = new TecnologyDAO();
                result = tecnologyDao.GetTecnologysByResource(resourceId);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return result;
        }
        public bool CheckName(int id, string name)
        {
            bool isValid = false; 
            TecnologyDAO tecnologydao;
            try
            {
                Logger.Info();
                tecnologydao = new TecnologyDAO();
                isValid = tecnologydao.CheckName(id, name);
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
            return isValid;
        }
    }
}
